home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / glass / glass.lha / GLASS / tm / debug.c < prev    next >
C/C++ Source or Header  |  1990-11-06  |  2KB  |  90 lines

  1. /* 
  2.    Copyright (C) 1990 C van Reewijk, email: dutentb.uucp!reeuwijk
  3.  
  4. This file is part of GLASS.
  5.  
  6. GLASS is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GLASS is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GLASS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* file: debug.c
  21.    variables and routines for debugging.
  22.  */
  23.  
  24. /* UNIX libraries */
  25. #include <stdio.h>
  26.  
  27. /* Local definitions */
  28. #include "debug.h"
  29.  
  30. #define TRUE 1
  31. #define FALSE 0
  32.  
  33. extern FILE *tracestream;
  34.  
  35. /* Switch on debugging flags given by the string 's'.
  36.    The flags are given in the table 'flagtab'.
  37.  */
  38. void setdbflags( s, flagtab )
  39.  char *s;
  40.  struct flagadrinfo *flagtab;
  41. {
  42.     register int c;
  43.     struct flagadrinfo *p;
  44.     register short int match;
  45.  
  46.     while( *s != '\0' ){
  47.     c = *s++;
  48.     p = flagtab;
  49.     match = FALSE;
  50.     while( p->flagchar != '\0' && match == FALSE ){
  51.         if( p->flagchar == c ){
  52.         *p->flagadr = TRUE;
  53.         match = TRUE;
  54.         }
  55.         p++;
  56.     }
  57.     if( match == FALSE ){
  58.         fprintf( stderr, "Unknown flag: '%c'\n", c );
  59.         exit( 1 );
  60.     }
  61.     }
  62. }
  63.  
  64. /* Give help information on debugging flags. */
  65. void dbhelp( flagtab )
  66.  struct flagadrinfo *flagtab;
  67. {
  68.     struct flagadrinfo *p;
  69.  
  70.     fprintf( stdout, "Debugging flags:\n" );
  71.     p = flagtab;
  72.     while( p->flagchar != '\0' ){
  73.     fprintf( stdout, " %c - %s.\n", p->flagchar, p->flagname );
  74.     p++;
  75.     }
  76. }
  77.  
  78. /* For all flags that are set report that fact to 'tracestream'. */
  79. void dbreport( flagtab )
  80.  register struct flagadrinfo *flagtab;
  81. {
  82.     struct flagadrinfo *p;
  83.  
  84.     p = flagtab;
  85.     while( p->flagchar != '\0' ){
  86.     if( *p->flagadr ) fprintf( tracestream, "%s.\n", p->flagname );
  87.     p++;
  88.     }
  89. }
  90.